From: Jyrki Gadinger Date: Thu, 9 Jan 2025 10:44:56 +0000 (+0100) Subject: fix window resize on DPI changes X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~2^2~133^2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=f352e8e2155a1b6dc74077b1a6f1abc037f88f23;p=nextcloud-desktop.git fix window resize on DPI changes This commit fixes #7678 and likely fixes #7447 too. On Windows, when the screen is changed to one with a different scaling setting the window is being incorrectly resized. This can be worked around by storing the window's size before moving it to a different screen, and then resizing the window again. Signed-off-by: Jyrki Gadinger --- diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index 8074a4b79..3c28aca04 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -588,11 +588,18 @@ void Systray::setSyncIsPaused(const bool syncIsPaused) void Systray::positionWindowAtTray(QQuickWindow *window) const { - if (!useNormalWindow()) { - window->setScreen(currentScreen()); - const auto position = computeWindowPosition(window->width(), window->height()); - window->setPosition(position); + if (useNormalWindow()) { + return; } + + // need to store the current window size before moving the window to another screen, + // otherwise it is being incorrectly resized by the OS or Qt when switching to a screen + // with a different DPI setting + const auto initialSize = window->size(); + const auto position = computeWindowPosition(initialSize.width(), initialSize.height()); + window->setPosition(position); + window->setScreen(currentScreen()); + window->resize(initialSize); } void Systray::positionWindowAtScreenCenter(QQuickWindow *window) const